home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-06-04 | 21.6 KB | 859 lines | [TEXT/MPS ] |
- // © 1991, Bowers Development Corp.
- // UAMLibraryM.cp
-
- #include "UAMLibraryM.h"
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- const long kStdGrayLine = 'Line';
- const long kStdPalette = 'Palt';
- const long kStdPictButton = 'pBut';
- const long kStdPictCheckBox = 'pChk';
- const long kStdPictRadio = 'pRad';
- const long kStdMultiPict = 'pMul';
- const long kStdSlider = 'Sldr';
- const long kStdCustom = 'Cust';
-
-
- #pragma segment AMControlRes
- /*----------*/
- pascal void ActionProcForTSlider (ControlHandle aCMgrControl,
- short partCode)
- {
- TSlider *aSlider;
-
- aSlider = (TSlider *) GetCRefCon (aCMgrControl);
- FailNIL (aSlider);
-
- aSlider->ActionProc (partCode);
- } /* ActionProcForTSlider */
-
-
- //-------------------------------------------------------
- // TGrayLine (TView) Gray line
- //-------------------------------------------------------
-
- #pragma segment ARes
- /*----------*/
- pascal void TGrayLine::Draw (const VRect& area)
- {
- PenState savePen;
-
- GetPenState (savePen);
- PenNormal ();
- PenPat (qd.gray);
- //????? the following is wrong. it should draw from view's coordinates not from rect's
- MoveTo (area.left, area.top);
- LineTo (area.right - 1, area.bottom - 1);
-
- SetPenState (savePen);
- } /* Draw */
-
- //-------------------------------------------------------
- // TPalette (TCtlMgr) Palette
- //-------------------------------------------------------
-
- #pragma segment AOpen
- /*----------*/
- pascal void TPalette::IPalette (TView *itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- short itsPictureID,
- short itsNumberAcross,
- short itsNumberDown,
- short itsFrameSize)
- {
- Str255 itsLabel;
-
- itsLabel [0] = 4;
- itsLabel [1] = (Byte) (itsPictureID >> 8);
- itsLabel [2] = (Byte) (itsPictureID & 0x00FF);
- itsLabel [3] = (Byte) itsNumberAcross;
- itsLabel [4] = (Byte) itsNumberDown;
-
- ICtlMgr (itsSuperView, itsLocation, itsSize,
- itsHSizeDet, itsVSizeDet, itsLabel,
- 1, 1, (itsNumberAcross * itsNumberDown),
- (kPaletteProcID + itsFrameSize));
- fDefChoice = mPaletteHit;
- } /* IPalette */
-
- #pragma segment AInit
- /*----------*/
- pascal void TPalette::IRes (TDocument *itsDocument,
- TView *itsSuperView,
- Ptr& itsParams)
- {
- VRect itsArea;
- Str255 itsLabel;
- PaletteTPtr ptPtr;
-
- inherited::IRes (itsDocument, itsSuperView, itsParams);
-
- fDefChoice = mPaletteHit;
- ptPtr = (PaletteTPtr) itsParams;
- itsLabel [0] = 4;
- itsLabel [1] = (Byte) (ptPtr->itsPictureID >> 8);
- itsLabel [2] = (Byte) (ptPtr->itsPictureID & 0x00FF);
- itsLabel [3] = (Byte) ptPtr->itsNumberAcross;
- itsLabel [4] = (Byte) ptPtr->itsNumberDown;
- ControlArea (itsArea);
- CreateCMgrControl (itsArea, itsLabel, 1, 1,
- (ptPtr->itsNumberDown * ptPtr->itsNumberAcross),
- (kPaletteProcID + ptPtr->itsFrameSize));
-
- OffsetPtr (itsParams, sizeof (PaletteTemplate));
- } /* IRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TPalette::WRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- Str255 theLabel;
- PaletteTPtr ptPtr;
-
- inherited::WRes (theResource, itsParams);
-
- GetText (theLabel);
- ptPtr = (PaletteTPtr) (ExpandPtr ((Handle)theResource, itsParams,
- sizeof (PaletteTemplate)) );
- ptPtr->itsPictureID = (short) ((theLabel [1] << 8) + theLabel [2]);
- ptPtr->itsNumberAcross = (short) theLabel [3];
- ptPtr->itsNumberDown = (short) theLabel [4];
- ptPtr->itsFrameSize = GetCVariant (fCMgrControl);
-
- } /* WRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TPalette::WriteRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- gWResSignature = kStdPalette;
- gWResType = "TPalette";
- WRes (theResource, itsParams);
- } /* WriteRes */
-
- #pragma segment AFields
- /*----------*/
- pascal void TPalette::Fields (TObject* obj)
- {
- obj->DoToField ("TPalette", NULL, bClass);
- inherited::Fields (obj);
- } /* Fields */
-
- //-------------------------------------------------------
- // TPictButton (TCtlMgr) Picture button
- //-------------------------------------------------------
-
- #pragma segment AOpen
- /*----------*/
- pascal void TPictButton::IPictButton (TView *itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- const Str255& itsPicts)
- {
- ICtlMgr (itsSuperView, itsLocation, itsSize,
- itsHSizeDet, itsVSizeDet, itsPicts,
- 0, 0, 1, kPictButtonProcID);
- fDefChoice = mButtonHit;
- } /* IPictButton */
-
- #pragma segment AInit
- /*----------*/
- pascal void TPictButton::IRes (TDocument *itsDocument,
- TView *itsSuperView,
- Ptr& itsParams)
- {
- VRect itsArea;
- PictControlTPtr ptPtr;
-
- inherited::IRes (itsDocument, itsSuperView, itsParams);
-
- fDefChoice = mButtonHit;
- ptPtr = (PictControlTPtr) itsParams;
- ControlArea (itsArea);
- CreateCMgrControl (itsArea, ptPtr->itsPictureIDs,
- 0, 0, 1, kPictButtonProcID);
-
- OffsetPtrWStr (itsParams, sizeof (PictControlTemplate));
- } /* IRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TPictButton::WRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- Str255 theLabel;
- PictControlTPtr ptPtr;
-
- inherited::WRes (theResource, itsParams);
-
- GetText (theLabel);
- ptPtr = (PictControlTPtr) (ExpandPtrWStr ((Handle)theResource, itsParams,
- sizeof (PictControlTemplate), theLabel [0]));
- CopyStr255 (theLabel, PRStr (ptPtr->itsPictureIDs));
- } /* WRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TPictButton::WriteRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- gWResSignature = kStdPictButton;
- gWResType = "TPictButton";
- WRes (theResource, itsParams);
- } /* WriteRes */
-
- #pragma segment AFields
- /*----------*/
- pascal void TPictButton::Fields (TObject* obj)
- {
- obj->DoToField ("TPictButton", NULL, bClass);
- inherited::Fields (obj);
- } /* Fields */
-
- //-------------------------------------------------------
- // TPictCheckBox (TCtlMgr) Picture check box
- //-------------------------------------------------------
-
- #pragma segment AOpen
- /*----------*/
- pascal void TPictCheckBox::IPictCheckBox (TView *itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- const Str255& itsPicts,
- Boolean isTurnedOn)
-
- {
- ICtlMgr (itsSuperView, itsLocation, itsSize,
- itsHSizeDet, itsVSizeDet, itsPicts,
- 0, 0, 1, kPictCheckProcID);
- SetState (isTurnedOn, kDontRedraw);
- fDefChoice = mCheckBoxHit;
- } /* IPictCheckBox */
-
- #pragma segment AInit
- /*----------*/
- pascal void TPictCheckBox::IRes (TDocument *itsDocument,
- TView *itsSuperView,
- Ptr& itsParams)
- {
- VRect itsArea;
- PictControlTPtr ptPtr;
-
- inherited::IRes (itsDocument, itsSuperView, itsParams);
-
- fDefChoice = mCheckBoxHit;
- ptPtr = (PictControlTPtr) itsParams;
- ControlArea (itsArea);
- CreateCMgrControl (itsArea, ptPtr->itsPictureIDs,
- 0, 0, 1, kPictCheckProcID);
-
- OffsetPtrWStr (itsParams, sizeof (PictControlTemplate));
- } /* IRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TPictCheckBox::WRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- Str255 theLabel;
- PictControlTPtr ptPtr;
-
- inherited::WRes (theResource, itsParams);
-
- GetText (theLabel);
- ptPtr = (PictControlTPtr) (ExpandPtrWStr ((Handle)theResource, itsParams,
- sizeof (PictControlTemplate), theLabel [0]));
- CopyStr255 (theLabel, PRStr (ptPtr->itsPictureIDs));
- } /* WRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TPictCheckBox::WriteRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- gWResSignature = kStdPictCheckBox;
- gWResType = "TPictCheckBox";
- WRes (theResource, itsParams);
- } /* WriteRes */
-
- #pragma segment ARes
- /*----------*/
- pascal void TPictCheckBox::DoEvent (EvtNumber eventNumber,
- TEvtHandler* source,
- TEvent* event)
- {
- if (eventNumber == mCheckBoxHit) {
- Toggle (kRedraw);
- }
- inherited::DoEvent (eventNumber, source, event);
- } /* DoEvent */
-
- #pragma segment ARes
- /*----------*/
- pascal Boolean TPictCheckBox::IsOn (void)
- {
- if (GetLongVal () != 0) {
- return (TRUE);
- } else {
- return (FALSE);
- }
- } /* IsOn */
-
- #pragma segment ARes
- /*----------*/
- pascal void TPictCheckBox::SetState (Boolean state,
- Boolean redraw)
- {
- SetLongVal (state, redraw);
- } /* SetState */
-
- #pragma segment ARes
- /*----------*/
- pascal void TPictCheckBox::Toggle (Boolean redraw)
- {
- SetLongVal (!IsOn (), redraw);
- } /* Toggle */
-
- #pragma segment ARes
- /*----------*/
- pascal void TPictCheckBox::ToggleIf (Boolean matchState,
- Boolean redraw)
- {
- if (IsOn () == matchState) {
- SetLongVal (!IsOn (), redraw);
- }
- } /* ToggleIf */
-
- #pragma segment AFields
- /*----------*/
- pascal void TPictCheckBox::Fields (TObject* obj)
- {
- obj->DoToField ("TPictCheckBox", NULL, bClass);
- inherited::Fields (obj);
- } /* Fields */
-
- //-------------------------------------------------------
- // TPictRadio (TCtlMgr) Picture radio button
- //-------------------------------------------------------
-
- #pragma segment AOpen
- /*----------*/
- pascal void TPictRadio::IPictRadio (TView *itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- const Str255& itsPicts,
- Boolean isTurnedOn)
- {
- ICtlMgr (itsSuperView, itsLocation, itsSize,
- itsHSizeDet, itsVSizeDet, itsPicts,
- 0, 0, 1, kPictRadioProcID);
- SetState (isTurnedOn, kDontRedraw);
- fDefChoice = mRadioHit;
- } /* IPictRadio */
-
- #pragma segment AInit
- /*----------*/
- pascal void TPictRadio::IRes (TDocument *itsDocument,
- TView *itsSuperView,
- Ptr& itsParams)
- {
- VRect itsArea;
- PictControlTPtr ptPtr;
-
- inherited::IRes (itsDocument, itsSuperView, itsParams);
-
- fDefChoice = mRadioHit;
- ptPtr = (PictControlTPtr) itsParams;
- ControlArea (itsArea);
- CreateCMgrControl (itsArea, ptPtr->itsPictureIDs,
- 0, 0, 1, kPictRadioProcID);
-
- OffsetPtrWStr (itsParams, sizeof (PictControlTemplate));
- } /* IRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TPictRadio::WRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- Str255 theLabel;
- PictControlTPtr ptPtr;
-
- inherited::WRes (theResource, itsParams);
-
- GetText (theLabel);
- ptPtr = (PictControlTPtr) (ExpandPtrWStr ((Handle)theResource, itsParams,
- sizeof (PictControlTemplate), theLabel [0]));
- CopyStr255 (theLabel, PRStr (ptPtr->itsPictureIDs));
- } /* WRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TPictRadio::WriteRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- gWResSignature = kStdPictRadio;
- gWResType = "TPictRadio";
- WRes (theResource, itsParams);
- } /* WriteRes */
-
- #pragma segment ARes
- /*----------*/
- pascal void TPictRadio::DoEvent (EvtNumber eventNumber,
- TEvtHandler* source,
- TEvent* event)
- {
- if ((eventNumber == mRadioHit) && !IsOn ()) {
- Toggle (kRedraw);
- }
- inherited::DoEvent (eventNumber, source, event);
- } /* DoEvent */
-
- #pragma segment ARes
- /*----------*/
- pascal Boolean TPictRadio::IsOn (void)
- {
- if (GetLongVal () != 0) {
- return (TRUE);
- } else {
- return (FALSE);
- }
- } /* IsOn */
-
- #pragma segment ARes
- /*----------*/
- pascal void TPictRadio::SetState (Boolean state,
- Boolean redraw)
- {
- SetLongVal (state, redraw);
- } /* SetState */
-
- #pragma segment ARes}
- /*----------*/
- pascal void TPictRadio::Toggle (Boolean redraw)
- {
- SetLongVal (!IsOn (), redraw);
- } /* Toggle */
-
- #pragma segment ARes
- /*----------*/
- pascal void TPictRadio::ToggleIf (Boolean matchState,
- Boolean redraw)
- {
- if (IsOn () == matchState) {
- SetLongVal (!IsOn (), redraw);
- }
- } /* ToggleIf */
-
- #pragma segment AFields
- /*----------*/
- pascal void TPictRadio::Fields (TObject* obj)
- {
- obj->DoToField ("TPictRadio", NULL, bClass);
- inherited::Fields (obj);
- } /* Fields */
-
- //-------------------------------------------------------
- // TMultiPict (TCtlMgr) Multi-picture control
- //-------------------------------------------------------
-
- #pragma segment AOpen
- /*----------*/
- pascal void TMultiPict::IMultiPict (TView *itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- const Str255& itsPicts,
- short curValue)
- {
- short numberOfPicts; // number of possible states for the control
-
- numberOfPicts = itsPicts [0] / 2; // 2 bytes for each picture ID
- ICtlMgr (itsSuperView, itsLocation, itsSize,
- itsHSizeDet, itsVSizeDet, itsPicts,
- 1, 1, numberOfPicts, kMultiPictProcID);
- SetVal (curValue, kDontRedraw);
- fDefChoice = mMultiPictHit;
- } /* IMultiPict */
-
- #pragma segment AInit
- /*----------*/
- pascal void TMultiPict::IRes (TDocument *itsDocument,
- TView *itsSuperView,
- Ptr& itsParams)
- {
- VRect itsArea;
- PictControlTPtr ptPtr;
- short numberOfPicts; // number of possible states for the control
-
- inherited::IRes (itsDocument, itsSuperView, itsParams);
-
- fDefChoice = mMultiPictHit;
- ptPtr = (PictControlTPtr) itsParams;
- numberOfPicts = (ptPtr->itsPictureIDs [0]) / 2; // 2 bytes for each picture ID
- ControlArea (itsArea);
- CreateCMgrControl (itsArea, ptPtr->itsPictureIDs,
- 1, 1, numberOfPicts, kMultiPictProcID);
-
- OffsetPtrWStr (itsParams, sizeof (PictControlTemplate));
- } /* IRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TMultiPict::WRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- Str255 theLabel;
- PictControlTPtr ptPtr;
-
- inherited::WRes (theResource, itsParams);
-
- GetText (theLabel);
- ptPtr = (PictControlTPtr) (ExpandPtrWStr ((Handle)theResource, itsParams,
- sizeof (PictControlTemplate), theLabel [0]));
- CopyStr255 (theLabel, PRStr (ptPtr->itsPictureIDs));
- } /* WRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TMultiPict::WriteRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- gWResSignature = kStdMultiPict;
- gWResType = "TMultiPict";
- WRes (theResource, itsParams);
- } /* WriteRes */
-
- #pragma segment ARes
- /*----------*/
- pascal void TMultiPict::DoEvent (EvtNumber eventNumber,
- TEvtHandler* source,
- TEvent* event)
- {
- if (eventNumber == mMultiPictHit) {
- Cycle (kRedraw);
- }
- inherited::DoEvent (eventNumber, source, event);
- } /* DoEvent */
-
- #pragma segment ARes
- /*----------*/
- pascal void TMultiPict::Cycle (Boolean redraw)
- {
- short curVal;
-
- curVal = GetVal ();
-
- if (curVal == GetMax ()) {
- curVal = GetMin ();
- } else {
- curVal++;
- }
- SetVal (curVal, redraw);
- } /* Cycle */
-
- #pragma segment AFields
- /*----------*/
- pascal void TMultiPict::Fields (TObject* obj)
- {
- obj->DoToField ("TMultiPict", NULL, bClass);
- inherited::Fields (obj);
- } /* Fields */
-
- //-------------------------------------------------------
- // TSlider (TCtlMgr) Custom slider
- //-------------------------------------------------------
-
- #pragma segment AOpen
- /*----------*/
- pascal void TSlider::ISlider (TView *itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- VHSelect itsDirection,
- const Str255& itsPicts,
- short itsProcID,
- long itsVal,
- long itsMin,
- long itsMax)
- {
- ICtlMgr (itsSuperView, itsLocation, itsSize,
- itsHSizeDet, itsVSizeDet, itsPicts, itsVal, itsMin, itsMax, itsProcID);
- fDirection = itsDirection;
- fDefChoice = mSliderHit;
- } /* ISlider */
-
- #pragma segment AInit
- /*----------*/
- pascal void TSlider::IRes (TDocument *itsDocument,
- TView *itsSuperView,
- Ptr& itsParams)
- {
- VRect itsArea;
- SliderTPtr stPtr;
-
- inherited::IRes (itsDocument, itsSuperView, itsParams);
-
- fDefChoice = mSliderHit;
- stPtr = (SliderTPtr) itsParams;
- ControlArea (itsArea);
- CreateCMgrControl (itsArea, stPtr->itsPictureIDs,
- 0, 0, 10, kSliderProcID + stPtr->itsVariantCode);
-
- if ((itsArea.bottom - itsArea.top)
- >= (itsArea.right - itsArea.left)) {
- fDirection = vSel;
- } else {
- fDirection = hSel;
- }
-
- OffsetPtrWStr (itsParams, sizeof (SliderTemplate));
- } /* IRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TSlider::WRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- Str255 theLabel;
- SliderTPtr stPtr;
-
- inherited::WRes (theResource, itsParams);
-
- GetText (theLabel);
- stPtr = (SliderTPtr) (ExpandPtrWStr ((Handle)theResource, itsParams,
- sizeof (SliderTemplate), theLabel [0]));
- stPtr->itsVariantCode = 0; // should be control's variant code
- CopyStr255 (theLabel, PRStr (stPtr->itsPictureIDs));
- } /* WRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TSlider::WriteRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- gWResSignature = kStdSlider;
- gWResType = "TSlider";
- WRes (theResource, itsParams);
- } /* WriteRes */
-
- #pragma segment ARes
- /*----------*/
- pascal void TSlider::DeltaValue (VCoordinate delta)
- {
- if (delta != 0) {
- if (delta > 0) {
- delta = Min (delta, fLongMax - fLongVal);
- } else {
- delta = Max (delta, fLongMin - fLongVal);
- }
-
- SetLongVal (fLongVal + delta, TRUE);
- }
- } /* DeltaValue */
-
- #pragma segment ASelCommand
- /*----------*/
- pascal void TSlider::DoMouseCommand (VPoint& theMouse,
- TToolboxEvent* event,
- Point hysteresis)
- {
- short partCode;
- VCoordinate oldLongValue;
- VCoordinate newLongValue;
-
- #if qDebug
- AssumeFocused ();
- #endif
-
- oldLongValue = fLongVal;
- partCode = TestControl (fCMgrControl, theMouse);
-
- switch (partCode) {
- case inUpButton:
- case inDownButton:
- case inPageUp:
- case inPageDown:
- partCode = TrackControl (fCMgrControl, theMouse, (ProcPtr)&ActionProcForTSlider);
- if (fLongVal != oldLongValue) {
- HandleEvent (fDefChoice, this, NULL);
- }
- break;
- case inThumb:
- if (TrackControl (fCMgrControl, theMouse, NULL) == inThumb) {
- if (GetVal () == GetMax ()) {
- newLongValue = fLongMax;
- } else {
- newLongValue = ((long) GetVal () << fBitsToShift);
- }
- SetLongVal(newLongValue, kRedraw);
- }
-
- if (fLongVal != oldLongValue) {
- HandleEvent (fDefChoice, this, NULL);
- }
- break;
- default:
- break;
- } /* switch */
-
- } /* DoMouseCommand */
-
- #pragma segment ARes
- /*----------*/
- pascal void TSlider::TrackSlider (short /* partCode */)
- {
- DeltaValue (1); // only one part code
- } /* TrackSlider */
-
- #pragma segment ASelCommand
- /*----------*/
- /* this is based on TScrollBar.ActionProc. I'm not completely sure it's right */
- pascal void TSlider::ActionProc (short partCode)
- {
- if (partCode != 0) {
- TrackSlider (partCode); // bounds checking?
- }
- Update ();
- if (Focus ()) {
- }
- } /* ActionProc */
-
- #pragma segment AFields
- /*----------*/
- pascal void TSlider::Fields (TObject* obj)
- {
- obj->DoToField ("TSlider", NULL, bClass);
- obj->DoToField ("fDirection", (Ptr)&fDirection, bVHSelect);
- inherited::Fields (obj);
- } /* Fields */
-
- //-------------------------------------------------------
- // TCustom (TCtlMgr) Other custom control
- //-------------------------------------------------------
-
- struct CntlTemplate {
- Rect boundsRect;
- short value;
- Boolean visible;
- Boolean filler1;
- short max;
- short min;
- short procID;
- long refCon;
- Str255 title;
- };
- typedef CntlTemplate *ControlTPtr, **ControlTHndl;
-
- #pragma segment AOpen
- /*----------*/
- pascal void TCustom::ICustom (TView *itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- short itsCntlID)
- {
- ControlTHndl itsCNTL;
- short min;
- short max;
-
- fCntlID = itsCntlID;
- itsCNTL = (ControlTHndl) Get1Resource ('CNTL', itsCntlID);
- LoadResource ((Handle) itsCNTL);
- HLock ((Handle) itsCNTL);
- min = (**itsCNTL).min;
- max = (**itsCNTL).max;
- ICtlMgr (itsSuperView, itsLocation, itsSize,
- itsHSizeDet, itsVSizeDet, (**itsCNTL).title,
- min, min, max, (**itsCNTL).procID);
- ReleaseResource ((Handle) itsCNTL);
- fDefChoice = mCustomHit;
- } /* ICustom */
-
- #pragma segment AInit
- /*----------*/
- pascal void TCustom::IRes (TDocument *itsDocument,
- TView *itsSuperView,
- Ptr& itsParams)
- {
- VRect itsArea;
- CustomControlTPtr ctPtr;
- ControlTHndl itsCNTL;
- short min;
- short max;
-
- inherited::IRes (itsDocument, itsSuperView, itsParams);
-
- fDefChoice = mCustomHit;
- ctPtr = (CustomControlTPtr) itsParams;
- fCntlID = ctPtr->itsCntlID;
- itsCNTL = (ControlTHndl) Get1Resource ('CNTL', ctPtr->itsCntlID);
- LoadResource ((Handle) itsCNTL);
- HLock ((Handle) itsCNTL);
- min = (**itsCNTL).min;
- max = (**itsCNTL).max;
- ControlArea (itsArea);
- CreateCMgrControl (itsArea, (**itsCNTL).title, min, min, max, (**itsCNTL).procID);
- ReleaseResource ((Handle) itsCNTL);
-
- OffsetPtr (itsParams, sizeof (CustomControlTemplate));
- } /* IRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TCustom::WRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- Str255 theLabel;
- CustomControlTPtr ctPtr;
-
- inherited::WRes (theResource, itsParams);
-
- ctPtr = (CustomControlTPtr) (ExpandPtr ((Handle)theResource, itsParams,
- sizeof (CustomControlTemplate)) );
- ctPtr->itsCntlID = fCntlID;
- } /* WRes */
-
- #pragma segment WriteRes
- /*----------*/
- pascal void TCustom::WriteRes (ViewRsrcHandle theResource,
- Ptr& itsParams)
- {
- gWResSignature = kStdCustom;
- gWResType = "TCustom";
- WRes (theResource, itsParams);
- } /* WriteRes */
-
- #pragma segment AFields
- /*----------*/
- pascal void TCustom::Fields (TObject* obj)
- {
- obj->DoToField ("TCustom", NULL, bClass);
- obj->DoToField ("fCntlID", (Ptr)&fCntlID, bInteger);
- inherited::Fields (obj);
- } /* Fields */
-
- /* UAMLibrary.cp */
-